Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/register

Package Overview
Dependencies
Maintainers
4
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/register

babel require hook

  • 7.25.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.5M
decreased by-55.42%
Maintainers
4
Weekly downloads
 
Created

What is @babel/register?

The @babel/register npm package is a Babel hook that automatically compiles files on the fly when they are required. It is primarily used during development to compile JavaScript files using Babel as soon as they are imported, which allows developers to write modern JavaScript without worrying about compatibility with the current Node.js environment.

What are @babel/register's main functionalities?

On-the-fly ES6/ESNext compilation

Automatically compiles ES6/ESNext files when they are required. This allows you to use new JavaScript features without pre-compiling your code.

require('@babel/register');
require('./my-es6-script.js');

Custom Babel configurations

Allows you to specify custom Babel configurations, such as presets and plugins, to be applied when compiling your JavaScript files.

require('@babel/register')({
  presets: ['@babel/preset-env'],
  plugins: ['@babel/plugin-transform-runtime']
});
require('./my-custom-babel-config-script.js');

Ignore specific files or directories

Provides an option to ignore specific files or directories during the compilation process, which can improve performance by skipping unnecessary files.

require('@babel/register')({
  ignore: [/node_modules/]
});
require('./my-script.js');

Source map support

Supports inline source maps, which can be useful for debugging by allowing you to trace back to the original source code.

require('@babel/register')({
  sourceMaps: 'inline'
});
require('./my-script-with-source-maps.js');

Other packages similar to @babel/register

FAQs

Package last updated on 22 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc